package cn.itcast.order.pojo;

/**
 * @author danDong
 * @date 2025-04-17 09:14:11
 */
public class Singleton {


    // 使用volatile关键字确保instance变量的可见性
    private static volatile Singleton instance;

    private Singleton() {
        // 私有构造方法防止外部实例化
    }

    public static Singleton getInstance() {
        if (instance == null) {
            synchronized (Singleton.class) {
                if (instance == null) {
                    instance = new Singleton();
                }
            }
        }
        return instance;
    }
}
